package com.xingzhengfan.eurekaclient;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import org.springframework.stereotype.Component;

@Component
public class OrderJob implements SimpleJob {

    private static Integer count = 0;

    @Override
    public void execute(ShardingContext shardingContext) {
        String printfStr = String.format("-----Thread ID:%s, 任务总片数:%s, 当前分片项:%s-----", Thread.currentThread().getId(), shardingContext.getShardingTotalCount(), shardingContext.getShardingItem());
        System.out.println(printfStr);
        System.out.println("count++: " + count++);
        System.out.println("shardingContext.getJobName(): " + shardingContext.getJobName());
        System.out.println("shardingContext.getJobParameter(): " + shardingContext.getJobParameter());
        System.out.println("shardingContext.getShardingParameter(): " + shardingContext.getShardingParameter());
        System.out.println("shardingContext.getTaskId(): " + shardingContext.getTaskId());
        System.out.print("\n\n\n");
    }
}
